/**
 * 项目名：admin
 * 包名：com.xuebang.admin.mapper
 * 文件名：suggestionMapper.java
 * 版本信息：@version 1.0
 * 日期：2016-2-29-上午1720:55
 */
package com.xuebang.admin.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

import com.xuebang.admin.entity.Friends;

public interface FriendsMapper extends BaseMapper<Friends> {

	/**
	 * 加载指定id的
	 */
	@Select("select * from friends where id=#{intid}")
	public Friends loadFriend(int intid);


	/**
	 * 加载
	 */
	@Select("select * from friends order by ifusing,ifindex,id")
	public List<Friends> loadFriends();
	/**
	 * 加载
	 */
	public List<Friends> findFriends(@Param("strFsriendsIDs")String[] strFsriendsIDs);
	/**
	 * 分类加载
	 */
	@Select("select * from friends where ifusing=#{ifusing} order by ifindex,id")
	public List<Friends> loadFriendsbyIfusing(int ifusing);


	/**
	 *查找
	 * 
	 * @param
	 */
	@Select("select * from friends where name = #{name} order by ifusing,ifindex,id")
	public List<Friends> searchByFriends(String name);


	/**
	 * 更新栏目
	 */
	@Update("update friends set name=#{name},web_url=#{webUrl},img_url=#{imgUrl},ifindex=#{ifindex},ifusing=#{ifusing},orderby=#{orderby} where id=#{id}")
	int updateFriends(Friends friends);
	
	/**
	 * 删除栏目
	 * 
	 * @param 
	 * 		fsriendsIDs
	 */
	public void deleteFriends(@Param("strFsriendsIDs")String[] strFsriendsIDs);
	/**
	 * 增加
	 */
	@Insert("insert into friends(id,name,web_url,img_url,ifindex,ifusing,orderby) " +
			"values(#{id},#{name},#{webUrl},#{imgUrl},#{ifindex},#{ifusing},#{orderby})")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", before = false, resultType = Integer.class)
	public void addFriends(Friends friends);

	/**
	 * 获得某种类型的数目
	 */
	@Select("select count(id) from friends where ifusing=#{ifusing}")
	public Integer getLinksNum(Integer ifusing);
}